package com.shum1n.gmall.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.shum1n.gmall.bean.UserAddress;
import com.shum1n.gmall.service.UserService;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

@RestController
public class OrderController {

    // dubbo 提供的refrence 注解，提供远程接口调用
    @Reference
//    @Autowired
    private UserService userService;


    @HystrixCommand(fallbackMethod = "xxxx")
    @RequestMapping("/initOrder")
    public List<UserAddress> initOrder(@RequestParam("uid") String userId){
        return userService.getUserAddressList(userId);
    }

    public List<UserAddress> xxxx(@RequestParam("uid") String userId){
        return Arrays.asList(new UserAddress("出错了，23333", "233"));
    }
}
